layui.define(['http'], function (exports) {
  var http = layui.http;

  var fileServiceApi = {
    // 获取显示标签列表
    async getShowTabList(tabId) {
      const url = `/BaseVideo/ShowTab?tabId=${tabId}`;
      let response = await http.reqAwait(url);
      return response;
    },
    // 获取单个显示标签信息
    async getShowTabInfo(id) {
      const url = `/BaseVideo/ShowTab/${id}`;
      let response = await http.reqAwait(url);
      return response;
    },
    // 创建显示标签
    async createShowTab(showTab) {
      const url = `/BaseVideo/ShowTab`;
      let response = await http.reqAwait(url, showTab, "post");
      return response;
    },
    // 删除显示标签
    async deleteShowTab(showTab) {
      const url = `/BaseVideo/ShowTab`;
      let response = await http.reqAwait(url, showTab, "delete");
      return response;
    },
    // 更新显示标签
    async updateShowTab(showTab) {
      const url = `/BaseVideo/ShowTab`;
      let response = await http.reqAwait(url, showTab, "put");
      return response;
    },

    // 获取时间标签列表
    async getTimeTabList() {
      const url = `/BaseVideo/TimeTab/List`;
      let response = await http.reqAwait(url);
      return response;
    },
    // 获取时间标签信息
    async getTimeTabInfo(id) {
      const url = `/BaseVideo/TimeTab/${id}`;
      let response = await http.reqAwait(url);
      return response;
    },
    // 创建时间标签
    async createTimeTab(timeTab) {
      const url = `/BaseVideo/TimeTab`;
      let response = await http.reqAwait(url, timeTab, "post");
      return response;
    },
    // 删除时间标签
    async deleteTimeTab(timeTab) {
      const url = `/BaseVideo/TimeTab`;
      let response = await http.reqAwait(url, timeTab, "delete");
      return response;
    },
    // 更新时间标签
    async updateTimeTab(timeTab) {
      const url = `/BaseVideo/TimeTab`;
      let response = await http.reqAwait(url, timeTab, "put");
      return response;
    },

    // 更新时间标签
    async resetThumbnails(id) {
      const url = `/BaseVideo/TimeTab/ResetThumbnails/${id}`;
      let response = await http.reqAwait(url, {}, "put");
      return response;
    },

    // 获取视频列表
    async getVideoList(tabId) {
      const url = `/BaseVideo/Video?tabId=${tabId}`;
      let response = await http.reqAwait(url);
      return response;
    },
    // 获取单个视频信息
    async getVideoInfo(id) {
      const url = `/BaseVideo/Video/${id}`;
      let response = await http.reqAwait(url);
      return response;
    },
    // 创建视频
    async createVideo(video) {
      const url = `/BaseVideo/Video`;
      let response = await http.reqAwait(url, video, "post");
      return response;
    },
    // 删除视频
    async deleteVideo(video) {
      const url = `/BaseVideo/Video`;
      let response = await http.reqAwait(url, video, "delete");
      return response;
    },
    // 更新视频
    async updateVideo(video) {
      const url = `/BaseVideo/Video`;
      let response = await http.reqAwait(url, video, "put");
      return response;
    },


    // 检查文件是否存在
    async checkFileExists(fileSize, sha256Hash) {
      const url = `/Uploader/FileExists`;
      let params = { fileSize: fileSize, sha256Hash: sha256Hash };
      let response = await http.reqAwait(url, params);
      return response;
    },
    // 上传文件
    async uploadFile(file) {
      const url = `/Uploader/Upload`;
      let formData = new FormData();
      formData.append('File', file);
      let response = await http.reqAwait(url, formData, "post");
      return response;
    }
  };

  // 导出模块
  exports('fileServiceApi', fileServiceApi);
});